package com.clwl.supervise.superviseapp.config;

import com.clwl.supervise.superviseapp.entity.result.ResultCode;
import com.clwl.supervise.superviseapp.entity.result.ResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 自定义错误拦截
 */
//@ControllerAdvice
public class CustomExceptionHandler {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /**
     * 拦截500返回的信息
     * @param ex
     * @return
     */
    @ExceptionHandler(Throwable.class)
    public  ResultEntity handle500Error(Throwable ex) {
        logger.error(ex.getMessage());
        logger.error(ex.getLocalizedMessage());
        return ResultEntity.error(ResultCode.SERVER_ERROR);
    }


}
